package com.ldcc.report_system.util.http.Interceptor;

import android.util.Log;

import okhttp3.logging.HttpLoggingInterceptor;

/**
 * @author wwj[yeshengkele@outlook.com]
 * @description 请求日志拦截器
 */
public class LogInterceptor {

    public static final String TAG = "================>Http请求：";

    /**
     * 日志拦截器,用于打印返回请求的结果
     *
     * @return 拦截器
     */
    public static HttpLoggingInterceptor logInterceptor() {
        HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor(message -> {
            // 打印日志
            Log.w(TAG, "log:" + message);
        });
        // 设置日志级别
        httpLoggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
        return httpLoggingInterceptor;
    }
}
